package com.donleo.security.controller;


import com.donleo.common.api.CommonResult;
import com.donleo.common.relation.UserLoginRecord;
import com.donleo.security.service.UserLoginRecordService;
import com.donleo.security.vo.UserLoginRecordVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * 用户登录记录表 前端控制器
 * </p>
 *
 * @author liangd
 * @since 2020-12-21
 */
@RestController
@RequestMapping("/userLoginRecord")
public class UserLoginRecordController {

    @Autowired
    private UserLoginRecordService userLoginRecordService;

    /**
     * 查询所有
     */
    @GetMapping("/findAll")
    public CommonResult getAllLoginRecord(UserLoginRecordVo userLoginRecordVo){
        List<UserLoginRecord> list=userLoginRecordService.getAllLoginRecord(userLoginRecordVo);
        long total = userLoginRecordService.getCount(userLoginRecordVo);
        return CommonResult.success(total,list);
    }

    /**
     * 批量删除
     */
    @PostMapping("/deletes")
    public CommonResult deletes(Integer[] ids){
        List<Integer> idsList = Arrays.asList(ids);
        return userLoginRecordService.deletes(idsList);
    }
}
